home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / flin-0.5 / flin-0 / flin-0.5.1 / misc.c < prev    next >
C/C++ Source or Header  |  1996-03-20  |  1KB  |  47 lines

  1. /*
  2. Copyright (C) 1995  Brian Cully
  3.  
  4. This program is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free Software
  6. Foundation; either version 2 of the License, or (at your option) any later
  7. version.
  8.  
  9. This program is distributed in the hope that it will be useful, but WITHOUT
  10. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  12. details.
  13.  
  14. You should have received a copy of the GNU General Public License along with
  15. this program; if not, write to the Free Software Foundation, Inc., 675 Mass
  16. Ave, Cambridge, MA 02139, USA.
  17.  
  18. please send patches or advice to: `shmit@kublai.com'
  19. */
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22.  
  23. /* Print an error message (str) on stderr and exit */
  24. void error(char *str, int line) {
  25.    fprintf(stderr, "%i: %s", line, str);
  26.    exit(1);
  27. }
  28.  
  29. /*
  30.  * chk_alloc()
  31.  *
  32.  * Input - size - number of bytes to allocate.
  33.  * Returns - pointer to allocated space.
  34.  *
  35.  * This is a simple wrapper for malloc, so that we don't
  36.  * need to worry about the return value of malloc being NULL
  37.  */
  38. void    *chk_alloc(size_t size)
  39. {
  40.     void    *retval;
  41.  
  42.     if ((retval = malloc(size)) == NULL)
  43.         error("Out Of Memory!\n", 0);
  44.  
  45.     return(retval);
  46. }
  47.